<?php

namespace plugin\admin\app\controller\material;


use plugin\admin\app\logic\font\FontLogic;
use plugin\admin\app\logic\material\MaterialLogic;
use support\Request;
use support\Response;
use plugin\admin\app\controller\AuthController;
use support\exception\BusinessException;

class IndexController extends AuthController
{
    
    /**
     * 浏览
     * @return Response
     */
    public function index(): Response
    {
        return view('material/index/index');
    }

    /**
     * 查询
     * @param Request $request
     * @return Response
     * @throws BusinessException
     */
    public function select(Request $request): Response
    {
        return MaterialLogic::getInstance()->select($request);
    }

    /**
     * 插入
     * @param Request $request
     * @return Response
     * @throws BusinessException
     */
    public function insert(Request $request): Response
    {
        if ($request->method() === 'POST') {
            return MaterialLogic::getInstance()->insert($request);
        }
        return view('material/index/insert');
    }

    /**
     * 更新
     * @param Request $request
     * @return Response
     * @throws BusinessException
    */
    public function update(Request $request): Response
    {
        if ($request->method() === 'POST') {
            return MaterialLogic::getInstance()->update($request);
        }
        return view('material/index/update');
    }

    /**
     * 删除
     * @param Request $request
     * @return Response
     * @throws \support\exception\BusinessException
     */
    public function delete(Request $request): Response
    {
        return MaterialLogic::getInstance()->delete($request);
    }

    /**
     * 视频明细
     * @param Request $request
     * @return Response
     * @throws BusinessException
     */
    public function video(Request $request): Response
    {
        return view('material/index/view');
    }

    /**
     * 同步素材视频
     * @param Request $request
     * @return Response
     * @throws BusinessException
     */
    public function sysncmaterial(Request $request): Response
    {
        return MaterialLogic::getInstance()->sysncmaterial($request);
    }
    
    /**
     * 查看列表
     * @return Response
     */
    public function list(Request $request): Response
    {
        return view('material/list/index');
    }
    
    /**
     * 同步全部素材视频
     * @return Response
     */
    public function sysncallmaterial(Request $request): Response
    {
        $result = MaterialLogic::getInstance()->sysncAllMaterial($request);
        return $result;
    }

    /**
     * 查询列表数据
     * @param Request $request
     * @return Response
     * @throws BusinessException
     */
    public function selectcos(Request $request): Response
    {
        return MaterialLogic::getInstance()->selectcos($request);
    }

    /**
     * 删除素材视频
     * @param Request $request
     * @return Response
     * @throws \support\exception\BusinessException
     */
    public function deletecos(Request $request): Response
    {
        return MaterialLogic::getInstance()->deletecos($request);
    }

}
